<?php

class SignupForm extends CFormModel
{
	public $email;
	public $username;
	public $password;
	public $password2;
	
	public function rules()
	{
		return array(
			// email, username and password are required
			array('email, password, username', 'required'),
			array('email','email'),
		);
	}
	
	public function signup()
	{
		$account = new Account;
		$account->email = $this->email;
		$account->password = md5($this->password);
		$account->username = $this->username;
		if($account->validate()){
			$account->save();
			return true;
		}
		return false;
	}
}